<?php $this->beginContent('//layouts/main_with_sidebar'); ?>
<?php

$this->sidebarTitle = 'Administration';
$this->menu = array(
	array(
		'label' => '<img src="/images/icons/fugue/user-business.png" width="16" height="16" /> Users',
		'url' => array('users/'),
		'items' => array(
			array(
				'label' => 'All Users',
				'url' => array('users/'),
				'active' => ($this->id == 'users' && in_array($this->action->id, array('index', 'view', 'update', 'bankinfo', 'commission', 'resetpw')))
			),
			array(
				'label' => 'Roles and Permissions',
				'url' => array('roles/'),
				'active' => $this->id == 'roles',
				'visible' => Yii::app()->user->hasOneAgencySelected() && Yii::app()->user->checkAccess('ManageAgency.Role.Manage')
			),
			array(
				'label' => 'Designations',
				'url' => array('hierarchy/'),
				'active' => in_array($this->id, array('designations', 'hierarchy')),
				'visible' => Yii::app()->user->hasOneAgencySelected() && Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission') && Yii::app()->user->checkAccess('ManageAgency.Designation.View')
			),
			array(
				'label' => 'Add New',
				'url' => array('users/adduser'),
				'active' => ($this->id == 'users' && $this->action->id == 'adduser'),
				'visible' => Yii::app()->user->checkAccess('ManageAgency.User.Manage')
			),
		),
		'visible' => Yii::app()->user->checkAccess('ManageAgency.User.View'),
		'active' => in_array($this->id, array('users', 'roles', 'hierarchy'))
	),
	array(
		'label' => '<img src="/images/icons/fugue/users.png" width="16" height="16" /> Teams',
		'url' => array('teams/'),
		'items' => array(
			array(
				'label' => 'All Teams',
				'url' => array('teams/'),
				'active' => ($this->id == 'teams' && in_array($this->action->id, array('index', 'view'))),
				'visible' => Yii::app()->user->checkAccess('ManageAgency.Team.View')
			),
			array(
				'label' => 'Add New',
				'url' => array('teams/create'),
				'active' => ($this->id == 'teams' && $this->action->id == 'create'),
				'visible' => Yii::app()->user->checkAccess('ManageAgency.Team.Manage')
			),
		),
		'visible' => Yii::app()->user->checkAccess('ManageAgency.Team.View'),
		'active' => in_array($this->id, array('teams'))
	),
	array(
		'label' => '<img src="/images/icons/fugue/user.png" width="16" height="16" /> Vendors',
		'url' => array('vendor/'),
		'items' => array(
			array(
				'label' => 'All Vendors',
				'url' => array('vendor/'),
				'active' => ($this->id == 'vendor' && in_array($this->action->id, array('index', 'view'))),
				'visible' => true // TODO: ADD PERMISSION
			),
			array(
				'label' => 'Add New',
				'url' => array('vendor/create'),
				'active' => ($this->id == 'vendor' && $this->action->id == 'create'),
				'visible' => true // TODO: ADD PERMISSION
			),
		),
		'visible' => Yii::app()->user->checkModuleAccess('Propsage.Vendor'),
		'active' => in_array($this->id, array('vendor'))
	),
	array(
		'label' => '<img src="/images/icons/farmfresh/16x16/database_go.png" width="16" height="16" /> Export Data',
		'url' => array('export/'),
		'items' => array(
			array(
				'label' => 'Invoices',
				'url' => array('export/invoices'),
				'active' => $this->action->id == 'invoices'
			),
			array(
				'label' => 'Receipts',
				'url' => array('export/receipts'),
				'active' => $this->action->id == 'receipts'
			),
			array(
				'label' => 'Payment Vouchers',
				'url' => array('export/paymentVouchers'),
				'active' => $this->action->id == 'paymentVouchers'
			),
			array(
				'label' => 'Commission Payable',
				'url' => array('export/commissionPayables'),
				'active' => $this->action->id == 'commissionPayables'
			),
			array(
				'label' => 'Transactions',
				'url' => array('export/transactions'),
				'active' => $this->action->id == 'transactions'
			),
			array(
				'label' => 'Team Performance',
				'url' => array('export/teamperformance'),
				'active' => $this->action->id == 'teamperformance'
			),
		),
		'active' => in_array($this->id, array('export'))
	),
	array(
		'label' => '<img src="/images/icons/fugue/gear.png" width="16" height="16" /> System Settings',
		'url' => array('system/'),
		'items' => array(
			array(
				'label' => 'Company Information',
				'url' => array('system/'),
				'active' => ($this->id == 'system' && in_array($this->action->id, array('update')))
			),
			array(
				'label' => 'Appearance',
				'url' => array('system/appearance'),
				'active' => ($this->id == 'system' && in_array($this->action->id, array('appearance')))
			),
			array(
				'label' => 'Numbering',
				'url' => array('system/numbering'),
				'active' => ($this->id == 'system' && in_array($this->action->id, array('numbering'))),
				'visible' => Yii::app()->user->hasOneAgencySelected()
			),
			array(
				'label' => 'Templates',
				'url' => array('templates/'),
				'active' => ($this->id == 'templates'),
				'visible' => Yii::app()->user->hasOneAgencySelected()
			),
			array(
				'label' => 'Custom Fields',
				'url' => array('customField/'),
				'active' => ($this->id == 'customField'),
				'visible' => Yii::app()->user->hasOneAgencySelected()
			),
			array(
				'label' => 'Custom Field Groups',
				'url' => array('customFieldGroup/'),
				'active' => ($this->id == 'customFieldGroup'),
				'visible' => Yii::app()->user->hasOneAgencySelected()
			),
		),
		'visible' => Yii::app()->user->checkAccess('ManageAgency.SystemSettings.Manage'),
		'active' => in_array($this->id, array('system', 'templates', 'customField', 'customFieldGroup'))
	),
	array(
		'label' => '<img src="/images/icons/farmfresh/16x16/plugin.png" width="16" height="16" /> Module Settings',
		'url' => array('modules/accounting'),
		'items' => array(
			'Accounting' => array(
				'label' => 'Accounting',
				'url' => array('modules/accounting'),
				'active' => $this->id == 'modules/accounting',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting'),
			),
			'Contacts' => array(
				'label' => 'Contacts',
				'url' => array('modules/contacts'),
				'active' => $this->id == 'modules/contacts',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission'),
			),
			'Commissions' => array(
				'label' => 'Commissions',
				'url' => array('modules/commissions'),
				'active' => $this->id == 'modules/commissions',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission'),
			),
			'Multiple Listing System' => array(
				'label' => 'Multiple Listing System',
				'url' => array('modules/mls'),
				'active' => $this->id == 'modules/mls',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.MLS'),
			),
			'Projects' => array(
				'label' => 'Projects',
				'url' => array('modules/projects'),
				'active' => $this->id == 'modules/projects',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Projects'),
			),
			'Tickets' => array(
				'label' => 'Tickets',
				'url' => array('modules/tickets'),
				'active' => $this->id == 'modules/tickets',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.TicketManagement'),
			),
			'Transaction' => array(
				'label' => 'Transaction',
				'url' => array('modules/transaction'),
				'active' => $this->id == 'modules/transaction',
			),
		),
		'visible' => Yii::app()->user->hasOneAgencySelected(),
		'active' => strpos($this->id, 'modules/') !== false
	),
	array(
		'label' => '<img src="/images/icons/farmfresh/16x16/server_information.png" width="16" height="16" /> System Information',
		'url' => array('systemInfo/'),
		'visible' => Yii::app()->user->checkAccess('ManageAgency.SystemSettings.Manage'),
		'active' => $this->id == 'systemInfo'
	)
);
?>
<?php echo $content; ?>
<?php $this->endContent(); ?>